package demo;

import com.google.gson.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;
import java.util.*;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UserListServlet extends HttpServlet{
	private static final Logger log = Logger.getLogger(UserListServlet.class.getName());
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws IOException{
		
		UserAO ao = new UserAO();
		Gson gson = new Gson();
		String json = null;
		
		Iterable<User> list= ao.getuserData();

		json = gson.toJson(list);
		
		resp.setContentType("text/plain");
		resp.getWriter().println("{\"aaData\":" + json +"}");	
		
		
	}

	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		doGet(req,resp);
	}
}
